const app = getApp()
Page({
  data: {
    loading: true,
    page: 0,
    store_id: 0,
    special: [],
  },
  //监听页面加载
  onLoad: function (options) {
    app.getParam(options,(param) => {
      this.setData({
        store_id: param.store_id,
      });
      this.getSpecial();
    })
  },
  //上拉加载
  onReachBottom: function () {
    this.setData({
      loading: true,
    });
    this.getSpecial();
  },
  //点击请求数据
  getSpecial: function () {
    if (this.data.loading) {
      var param = {
        signkey: app.util().getRandom(12),
        store_id: this.data.store_id,
        page: this.data.page + 1,
        types:0,
      }
      app.api().Get('api/v4/allwin/shop/goods', param, (result) => {
        if (result.code == 200) {
          var special = this.data.special;
          for (let i in result.data) {
            special.push(result.data[i]);
          }
          this.setData({
            special: special,
            page: param.page,
          });
        }
        this.setData({
          loading: false,
        });
      })
    }
  },
  //分享按钮
  onShareAppMessage: function () {
    return {
      title: app.globalData.appConfig.shop_share_text,
      imageUrl: app.globalData.appConfig.shop_share_img,
      path: '/pages/store/views?ucode=' + app.globalData.loginuser.ucode + '&store_id=' + this.data.store_id
    }
  }
})